<template>
    <ztree :data="data"
           @nodeClick="nodeClick"
           @selectUser="selectUser"
           :show-checkBox="showCheckBox"
           :name="'departName'"></ztree>
</template>
<script>
import ztree from './index';
import { Scroller } from 'vux';
export default {
    components: {
        ztree,
        Scroller
    },
    data () {
        return {
            data: [],
            users: [],
            showCheckBox: true
        }
    },
    created () {
        this.userInfo = JSON.parse(localStorage.userInfo)
        this.userId = this.userInfo.userid
        this.tokenId = this.userInfo.tokenId
        this.projectId = this.userInfo.deptid
        this.business = this.$route.query.business || 'GetHdProjects';
    },
    mounted () {
        let param = {
            allowPaging: true,
            business: this.business,
            data: this.projectId,
            pageIndex: 0,
            pageSize: 20,
            tokenId: this.tokenId,
            userId: this.userId
        }
        this.$axiosAjax.getConfigJson(param).then(res => {
            this.theModel = res.data.data
        })
    },
    methods: {
        nodeClick (data) {
            let param = {
                allowPaging: true,
                business: 'getPersonPage',
                data: {
                    Identity: '',
                    Name: '',
                    departId: this.projectId
                },
                pageIndex: 0,
                pageSize: 20,
                tokenId: this.tokenId,
                userId: this.userId
            }
            this.$axiosAjax
                .getConfigJson(param)
                .then(res => {
                    if (res.data.success == true) {
                        data.users = res.data.result.items
                    }
                })
                .catch(err => { })
        },
        selectUser (data) {
            this.$emit('selectUser', data)
        }
    }
}
</script>
